| API Documentation |  |

- MAIN PAGE
- NAMESPACES
- CLASSES

Environment.h
1 // Environment.h
3 //
5
6 namespace nkScripts
7 {
13 class Environment final
14 {
15 public :
16
20 virtual ~Environment () ;
21
22 // Getters
26 const ExecutionResult& getLastExecutionResult () const ;
30 nkMemory::StringView getName () const ;
31
32 // Setters
38 void setEnvironmentFor (INTERPRETER interpretType) ;
46 void setName (nkMemory::StringView name) ;
47
48 // Execution
55 bool execute (const Script& script) ;
59 void requestGarbageCollection () ;
60
61 // Manipulating memory
68 void setVar (nkMemory::StringView name, bool value) ;
75 void setVar (nkMemory::StringView name, int value) ;
82 void setVar (nkMemory::StringView name, float value) ;
89 void setVar (nkMemory::StringView name, double value) ;
96 void setVar (nkMemory::StringView name, const char* value) ;
103 void setVar (nkMemory::StringView name, nkMemory::StringView value) ;
110 void setVar (nkMemory::StringView name, const ScriptObjectReference& value) ;
118 void setObject (nkMemory::StringView name, nkMemory::StringView userTypeName, void* value) ;
119
125 bool isVarSet (nkMemory::StringView name) ;
126
136 bool getVar (nkMemory::StringView name, bool defaultValue) ;
146 int getVar (nkMemory::StringView name, int defaultValue) ;
156 float getVar (nkMemory::StringView name, float defaultValue) ;
166 double getVar (nkMemory::StringView name, double defaultValue) ;
176 nkMemory::StringView getVar (nkMemory::StringView name, const char* defaultValue) ;
186 nkMemory::StringView getVar (nkMemory::StringView name, nkMemory::StringView defaultValue) ;
195 ScriptObjectReference getVar (nkMemory::StringView name) ;
206 void* getObject (nkMemory::StringView name, nkMemory::StringView userTypeName = nullptr) ;
215 ScriptObjectReference getScriptFunction (nkMemory::StringView name) ;
216
225 Function* setFunc (nkMemory::StringView name) ;
232 bool isFuncSet (nkMemory::StringView name) ;
237 Function* getFunc (nkMemory::StringView name) ;
238
247 UserType* setUserType (nkMemory::StringView name) ;
254 bool isUserTypeSet (nkMemory::StringView name) ;
259 UserType* getUserType (nkMemory::StringView name) ;
260
268 Namespace* setNamespace (nkMemory::StringView name) ;
275 bool isNamespaceSet (nkMemory::StringView name) ;
280 Namespace* getNamespace (nkMemory::StringView name) ;
281
282 // Call C++ -> Script
291 bool callScriptFunction (const ScriptObjectReference& reference, const DataStack& args, DataStack& expectedOutput) ;
292
302 nkMemory::Buffer serializeScriptObject (const ScriptObjectReference& reference, bool forwardUserDataOwnership = false) ;
309 ScriptObjectReference deserializeScriptObject (nkMemory::BufferView<unsigned char> object) ;
310
311 public :
312
313 public :
314
315 // Statics
322 static nkMemory::UniquePtr<Environment> create () noexcept ;
329 static nkMemory::UniquePtr<Environment> create (Environment&& other) noexcept ;
330 } ;
331 }
332
nkScripts::Environment::isNamespaceSet
bool isNamespaceSet(nkMemory::StringView name)
nkScripts::Environment::setVar
void setVar(nkMemory::StringView name, const ScriptObjectReference &value)
nkScripts::Environment::getUserType
UserType * getUserType(nkMemory::StringView name)
nkScripts::Environment
Defines an environment in which scripts can execute.
Definition: Environment.h:14
nkScripts
Encompasses all API of component NilkinsScripts.
Definition: Environment.h:7
nkScripts::Environment::isUserTypeSet
bool isUserTypeSet(nkMemory::StringView name)
nkScripts::Namespace
Holds information and allow control over a namespace in a scripting environment.
Definition: Namespace.h:12
nkScripts::Script
Holds all information for a script.
Definition: Script.h:14
nkScripts::Environment::setUserType
UserType * setUserType(nkMemory::StringView name)
nkMemory::BufferView
A view over data.
Definition: BufferView.h:18
nkScripts::Environment::setEnvironmentFor
void setEnvironmentFor(INTERPRETER interpretType)
nkScripts::Environment::getVar
double getVar(nkMemory::StringView name, double defaultValue)
nkScripts::Environment::getObject
void * getObject(nkMemory::StringView name, nkMemory::StringView userTypeName=nullptr)
nkScripts::Environment::getVar
int getVar(nkMemory::StringView name, int defaultValue)
nkScripts::Environment::isFuncSet
bool isFuncSet(nkMemory::StringView name)
nkScripts::Environment::getVar
bool getVar(nkMemory::StringView name, bool defaultValue)
nkScripts::Environment::setVar
void setVar(nkMemory::StringView name, int value)
nkScripts::Environment::~Environment
virtual ~Environment()
nkScripts::UserType
Represents a user type and all the information and control related.
Definition: UserType.h:27
nkMemory::Buffer
A buffer holding binary data.
Definition: Buffer.h:32
nkScripts::Environment::getFunc
Function * getFunc(nkMemory::StringView name)
nkScripts::Environment::isVarSet
bool isVarSet(nkMemory::StringView name)
nkScripts::ScriptObjectReference
A reference over an object in the scripting environment.
Definition: ScriptObjectReference.h:30
nkScripts::Environment::setObject
void setObject(nkMemory::StringView name, nkMemory::StringView userTypeName, void *value)
nkScripts::Environment::callScriptFunction
bool callScriptFunction(const ScriptObjectReference &reference, const DataStack &args, DataStack &expectedOutput)
nkScripts::Environment::setVar
void setVar(nkMemory::StringView name, double value)
nkMemory::UniquePtr
Smart pointer owning the object instance it encapsulates.
Definition: UniquePtr.h:17
nkScripts::Environment::getVar
float getVar(nkMemory::StringView name, float defaultValue)
nkScripts::Environment::setFunc
Function * setFunc(nkMemory::StringView name)
nkScripts::Environment::getNamespace
Namespace * getNamespace(nkMemory::StringView name)
nkMemory::StringView
Class holding information about a string, with no ownership over the data.
Definition: StringView.h:22
nkScripts::ExecutionResult
Holds information about the execution result of a script in an environment.
Definition: ExecutionResult.h:26
nkScripts::INTERPRETER
INTERPRETER
Supported scripting environments.
Definition: Interpreter.h:12
nkScripts::Environment::setNamespace
Namespace * setNamespace(nkMemory::StringView name)
nkScripts::Environment::setVar
void setVar(nkMemory::StringView name, nkMemory::StringView value)
nkScripts::Environment::requestGarbageCollection
void requestGarbageCollection()
nkScripts::Environment::getVar
nkMemory::StringView getVar(nkMemory::StringView name, const char *defaultValue)
nkScripts::Environment::setVar
void setVar(nkMemory::StringView name, const char *value)
nkScripts::Environment::getName
nkMemory::StringView getName() const
nkScripts::Environment::execute
bool execute(const Script &script)
nkScripts::Environment::deserializeScriptObject
ScriptObjectReference deserializeScriptObject(nkMemory::BufferView< unsigned char > object)
nkScripts::Environment::getVar
nkMemory::StringView getVar(nkMemory::StringView name, nkMemory::StringView defaultValue)
nkScripts::Environment::setVar
void setVar(nkMemory::StringView name, bool value)
nkScripts::Environment::getScriptFunction
ScriptObjectReference getScriptFunction(nkMemory::StringView name)
nkScripts::Function
Holds information, and controls, over a function in a scripting environment.
Definition: Function.h:50
nkScripts::Environment::getVar
ScriptObjectReference getVar(nkMemory::StringView name)
nkScripts::Environment::setVar
void setVar(nkMemory::StringView name, float value)
nkScripts::Environment::serializeScriptObject
nkMemory::Buffer serializeScriptObject(const ScriptObjectReference &reference, bool forwardUserDataOwnership=false)
nkScripts::Environment::getLastExecutionResult
const ExecutionResult & getLastExecutionResult() const
nkScripts::Environment::setName
void setName(nkMemory::StringView name)
nkScripts::Environment::create
static nkMemory::UniquePtr< Environment > create() noexcept
nkMemory
Encompasses all API of component NilkinsMemory.
Definition: Allocator.h:7